*,
*:before,
*:after {
	-webkit-box-sizing: border-box;
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

:root {
	font-size: 10px;
}

body {
	background-color: #111;
}

main {
	background-color: #b8803b;
	display: -webkit-box;
	display: -ms-flexbox;
	display: flex;
	-webkit-box-pack: center;
	-ms-flex-pack: center;
	justify-content: center;
	-webkit-box-align: center;
	-ms-flex-align: center;
	align-items: center;
	height: 100vh;
	margin: auto;
	overflow: hidden;
	position: relative;
	-webkit-perspective: 720px;
	perspective: 720px;
	white-space: nowrap;
	max-width: 720px;
}

.column {
	position: absolute;
	-webkit-transform: translateZ(0);
	transform: translateZ(0);
}

.column:nth-child(2) {
	-webkit-transform: translateZ(-21em);
	transform: translateZ(-21em);
	z-index: -1;
}

.column:nth-child(3) {
	-webkit-transform: translateZ(-42em);
	transform: translateZ(-42em);
	z-index: -2;
}

.column:nth-child(4) {
	-webkit-transform: translateZ(-63em);
	transform: translateZ(-63em);
	z-index: -3;
}

.column:nth-child(5) {
	-webkit-transform: translateZ(-84em);
	transform: translateZ(-84em);
	z-index: -4;
}

.column:nth-child(6) {
	-webkit-transform: translateZ(-105em);
	transform: translateZ(-105em);
	z-index: -5;
}

.column:nth-child(7) {
	-webkit-transform: translateZ(-126em);
	transform: translateZ(-126em);
	z-index: -6;
}

.column:nth-child(8) {
	-webkit-transform: translateZ(-147em);
	transform: translateZ(-147em);
	z-index: -7;
}

.column:nth-child(9) {
	-webkit-transform: translateZ(-168em);
	transform: translateZ(-168em);
	z-index: -8;
}

.soldier {
	-webkit-animation: march 2.5s ease-out infinite;
	animation: march 2.5s ease-out infinite;
	display: inline-block;
	position: relative;
	width: 15em;
	height: 21em;
	-webkit-transform: translate(-50%);
	transform: translate(-50%);
	will-change: transform;
	z-index: 0;
}

.soldier div {
	position: absolute;
}


/* Uniform color */

.torso,
.hat {
	background-color: #a02;
}


/* Skin */

.head,
.hand {
	background-color: #fdb;
}


/* Head */

.head {
	background-image: linear-gradient(85deg, transparent 55%, #fff 55%, #fff 65%, transparent 65%);
	border-radius: 50%;
	top: -2.6em;
	left: 0;
	width: 3em;
	height: 3em;
}

.hat {
	background-image: radial-gradient(1.5em 0.25em at 100% 65%, #fff 1.4em, transparent 1.5em);
	border-radius: 50% / 0.25em;
	bottom: 2em;
	height: 4.5em;
	width: 3em;
	z-index: 1;
}

.visor {
	background-color: #000;
	border-radius: 50%;
	top: 0.6em;
	left: 1.5em;
	height: 0.5em;
	width: 2.5em;
}


/* Torso */

.torso {
	background-image: radial-gradient(2.5em 1em at 50% 0, transparent 60%, #fff 60%, #fff 99%, transparent 99%), radial-gradient(6em 4em at 50% 0, transparent 85%, #fff 85%, #fff 99%, transparent 99%);
	border-radius: 2em 2em 0.4em 0.4em;
	top: 6em;
	left: 6em;
	width: 3em;
	height: 7em;
	-webkit-transform-origin: 50% 6em;
	transform-origin: 50% 6em;
}

.wind-up-handle {
	-webkit-animation: unwind 2.5s linear infinite;
	animation: unwind 2.5s linear infinite;
	background: radial-gradient(0.5em 0.5em at 0.5em 0.5em, transparent 39%, #ccc 40%, #ccc 98%, transparent 99%), radial-gradient(0.5em 0.5em at 0.5em 1.5em, transparent 39%, #ccc 40%, #ccc 98%, transparent 99%), -webkit-gradient(linear, left top, left bottom, color-stop(40%, transparent), color-stop(40%, #ccc), color-stop(60%, #ccc), color-stop(60%, transparent)) 0.2em 0 no-repeat;
	background: radial-gradient(0.5em 0.5em at 0.5em 0.5em, transparent 39%, #ccc 40%, #ccc 98%, transparent 99%), radial-gradient(0.5em 0.5em at 0.5em 1.5em, transparent 39%, #ccc 40%, #ccc 98%, transparent 99%), linear-gradient(transparent 40%, #ccc 40%, #ccc 60%, transparent 60%) 0.2em 0 no-repeat;
	top: 50%;
	right: 100%;
	width: 1.5em;
	height: 2em;
}


/* Pivot points and animations for arms and legs */

.left-arm,
.right-arm,
.left-leg,
.right-leg,
.ankle {
	-webkit-transform-origin: 1em 1em;
	transform-origin: 1em 1em;
}

.right-arm,
.left-leg,
.right-leg {
	-webkit-animation: pivot 1.25s ease-out infinite;
	animation: pivot 1.25s ease-out infinite;
}

.left-arm,
.left-leg {
	-webkit-animation-delay: -0.625s;
	animation-delay: -0.625s;
}


/* Arms */

.left-arm,
.right-arm {
	background-color: #c24;
}

.left-arm {
	-webkit-animation: rock 1.25s ease-out infinite;
	animation: rock 1.25s ease-out infinite;
	background-image: -webkit-gradient(linear, left top, left bottom, color-stop(68%, transparent), color-stop(68%, #fff));
	background-image: linear-gradient(transparent 68%, #fff 68%);
	top: 2.75em;
	left: 1em;
	width: 2em;
	height: 3em;
	-webkit-transform: rotate(-60deg);
	transform: rotate(-60deg);
	-webkit-transform-origin: 50% 0;
	transform-origin: 50% 0;
	z-index: -1;
}

.right-arm {
	background-image: -webkit-gradient(linear, left top, left bottom, color-stop(84%, transparent), color-stop(84%, #fff));
	background-image: linear-gradient(transparent 84%, #fff 84%);
	border-radius: 1em 1em 0 0;
	top: 0.5em;
	left: 0.5em;
	width: 2em;
	height: 6em;
	z-index: 1;
}


/* Musket parts */

.musket,
.butt {
	background-color: #222;
}

.musket {
	border-radius: 0.3em 0.3em 0 0;
	width: 0.7em;
	height: 11em;
	left: 2.5em;
	bottom: 0.5em;
}

.bayonet {
	-webkit-box-shadow: -0.2em -0.4em 0 #333 inset;
	box-shadow: -0.2em -0.4em 0 #333 inset;
	bottom: 95%;
	width: 1em;
	height: 4em;
}

.butt {
	background-color: #222;
	border-radius: 0.3em;
	right: 0;
	top: 9em;
	width: 1.1em;
	height: 3.5em;
}


/* Hand positions */

.hand {
	top: 100%;
}

.left-arm .hand {
	border-radius: 0.5em 1em 1em 1em;
	left: 25%;
	width: 2.5em;
	height: 1.5em;
}

.right-arm .hand {
	border-radius: 0.5em 0.5em 50% 50%;
	top: 100%;
	height: 2em;
	width: 2em;
}


/* Legs */

.left-leg,
.right-leg,
.ankle,
.foot {
	background-color: #111;
}

.left-leg,
.right-leg,
.ankle {
	width: 2em;
	height: 5.5em;
}

.left-leg,
.right-leg {
	border-radius: 1em;
	top: 6em;
	left: 0.5em;
}

.ankle {
	border-radius: 1em 1em 0 0;
	top: 3.5em;
}

.foot {
	border-radius: 1em 2em 1em 0.5em / 1.5em 1.5em 0.5em 0.5em;
	top: 4.5em;
	left: -0.3em;
	width: 3.5em;
	height: 1em;
}

@-webkit-keyframes march {
	from {
		-webkit-transform: translateX(-50%);
		transform: translateX(-50%);
	}
	25% {
		-webkit-transform: translateX(-25%);
		transform: translateX(-25%);
	}
	50% {
		-webkit-transform: translateX(0);
		transform: translateX(0);
	}
	75% {
		-webkit-transform: translateX(25%);
		transform: translateX(25%);
	}
	to {
		-webkit-transform: translateX(50%);
		transform: translateX(50%);
	}
}

@keyframes march {
	from {
		-webkit-transform: translateX(-50%);
		transform: translateX(-50%);
	}
	25% {
		-webkit-transform: translateX(-25%);
		transform: translateX(-25%);
	}
	50% {
		-webkit-transform: translateX(0);
		transform: translateX(0);
	}
	75% {
		-webkit-transform: translateX(25%);
		transform: translateX(25%);
	}
	to {
		-webkit-transform: translateX(50%);
		transform: translateX(50%);
	}
}

@-webkit-keyframes pivot {
	from,
	to {
		-webkit-transform: rotate(22deg);
		transform: rotate(22deg);
	}
	50% {
		-webkit-transform: rotate(-22deg);
		transform: rotate(-22deg);
	}
}

@keyframes pivot {
	from,
	to {
		-webkit-transform: rotate(22deg);
		transform: rotate(22deg);
	}
	50% {
		-webkit-transform: rotate(-22deg);
		transform: rotate(-22deg);
	}
}

@-webkit-keyframes rock {
	from,
	to {
		-webkit-transform: rotate(-60deg);
		transform: rotate(-60deg);
	}
	50% {
		-webkit-transform: rotate(-62deg);
		transform: rotate(-62deg);
	}
}

@keyframes rock {
	from,
	to {
		-webkit-transform: rotate(-60deg);
		transform: rotate(-60deg);
	}
	50% {
		-webkit-transform: rotate(-62deg);
		transform: rotate(-62deg);
	}
}

@-webkit-keyframes unwind {
	from {
		-webkit-transform: rotateX(0);
		transform: rotateX(0);
	}
	to {
		-webkit-transform: rotateX(1turn);
		transform: rotateX(1turn);
	}
}

@keyframes unwind {
	from {
		-webkit-transform: rotateX(0);
		transform: rotateX(0);
	}
	to {
		-webkit-transform: rotateX(1turn);
		transform: rotateX(1turn);
	}
}


/* Hide some offscreen soldiers based on viewport for performance reason */

@media screen and (max-width: 500px) {
	.soldier:first-child,
	.soldier:last-child {
		visibility: hidden;
	}
}

@media screen and (max-width: 320px) {
	.soldier:nth-child(-n + 2),
	.soldier:nth-child(n + 7) {
		visibility: hidden;
	}
}